<blockquote>
    <p>简单Restful例子</p>
</blockquote>
<h5>示例</h5>
<pre class="code brush:java">
package cn.jants.demos;


import cn.jants.common.annotation.action.Controller;
import cn.jants.common.annotation.action.GET;
import cn.jants.common.annotation.boot.PropertyConfiguration;
import cn.jants.common.annotation.service.Application;
import cn.jants.common.annotation.service.Autowired;
import cn.jants.core.context.AppConfiguration;
import cn.jants.core.startup.JTomcat;
import cn.jants.plugin.db.Db;
import cn.jants.restful.render.Json;

import java.util.List;

/**
 * Tomcat 方式启动
 *
 * @author MrShun
 * @version 1.0
 * @Date 2017/12/20
 */
@Application
@PropertyConfiguration
@Controller
public class DemosApplication extends AppConfiguration {

    /**
     * 可以注入Db实例使用
     */
    @Autowired
    private Db db;

    /**
     * Restful Get Api
     */
    @GET("/test")
    public Object test() {
        List list = db.list("select * from member");
        return Json.success(list);
    }

    public static void main(String[] args) {
        JTomcat.run(DemosApplication.class, 80);
    }
}
</pre>
<blockquote>
    <p>输出</p>
    <footer>访问地址 ：http://127.0.0.1/test</footer>
</blockquote>
<pre class="code brush:java">
{
  "code": 0,
  "data": [
    {
      "birthday": "",
      "create_time": "",
      "open_id": "49b02f45-25a7-459e-9f33-9b4c1f3cc80",
      "nick_name": "白不黑",
      "sex": "",
      "is_lock": 0,
      "tel": "15675428654",
      "id": 2,
      "avatar": "/static/tx.jpg",
      "type": 0,
      "account": "Aray666",
      "email": "530774513@qq.com"
    },
    {
      "birthday": "",
      "create_time": "",
      "open_id": "40ce47a3-99ab-4449-9c0b-5a5f3e1c35bb",
      "nick_name": "黑不白2",
      "sex": "",
      "is_lock": 0,
      "tel": "15675428654",
      "id": 6,
      "avatar": "/static/tx.jpg",
      "type": 0,
      "account": "testoo",
      "email": "530774513@qq.com"
    }
  ],
  "message": "ok"
}
</pre>
<script type="text/javascript">
    $(function () {
        SyntaxHighlighter.highlight();
        $(".toolbar").remove();
    });
</script>